﻿namespace DesignModeConsole.行为型.策略模式;

/// <summary>
/// 策略模式
/// </summary>
public class StrategyDesignService : IService
{
    public void Main()
        
    {
        #region 运行时候确定使用哪种策略

        // 无状态策略对象获取
        IStrategy a = NoStateObjectStrategyFactory.GetStrategy("A");
        a.AlgorithmInterface();

        // 包含策略的对象获取
        IStrategy b = ContainStateObjectStrategyFactory.GetStrategy("B");
        b.AlgorithmInterface();
        
        // 反射创建
        IStrategy c = ReflectStrategyFactory.GetStrategy("B");
        c.AlgorithmInterface();

        #endregion

        #region 静态编译时确定使用哪个策略

        IStrategy strategy = new ConcreteStrategyA();
        strategy.AlgorithmInterface();

        #endregion
    }
}